package com.effectivsocial.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import org.hibernate.envers.Audited;
import org.hibernate.envers.NotAudited;


@Entity
@Table(name = "t_link")
@Audited
@ToString
public class Link implements Serializable {

	private static final long serialVersionUID = 1L;
	
	
	@Id
	@Getter @Setter
	@Column(name="name")
	private String name;
	
	@Getter @Setter
	@Column(name = "label_key")
	private String labelKey;
	
	@Getter @Setter
	@Column(name = "href")
	private String href;
	
		
	@Getter @Setter
	@Column(name = "js_function")
	private String jsFunction;
	
	@Getter @Setter
	@Column(name = "link_type")
	private String linkType;

	@NotAudited
	@Getter @Setter
	@ManyToMany(mappedBy="links")   
	private List<LinkGroup> groups;
	
	@Getter @Setter
	@Transient
	private boolean header;
	
	@NotAudited
	@Getter @Setter
    @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinTable(name = "t_link_role", joinColumns = { @JoinColumn(name = "link_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") })
    private List<Role> roles;
}
